/*
 * Copyright (c) 2022-2022 All rights Reserved.
 */

package com.driving.core.mapper.type;

import org.apache.commons.lang3.StringUtils;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

/**
 * 驾驶证类型
 *
 * @author SAGITTAR
 * @since 2017
 */
@Getter
@RequiredArgsConstructor
public class LicenseType {

    private final String licenseCode;
    private final String description;

    public LicenseType(String licenseCode) {
        this(licenseCode, StringUtils.EMPTY);
    }

    /**
     * 由驾驶证代码，转换驾驶证类型
     *
     * @param type 驾驶证代码，如C1，C2等
     * @return 由驾驶证代码，转换驾驶证类型
     */
    public static LicenseType fromType(String type) {
        if (StringUtils.equalsIgnoreCase(type, "A1")) {
            return new LicenseType("A1");
        }
        if (StringUtils.equalsIgnoreCase(type, "A2")) {
            return new LicenseType("A2");
        }
        if (StringUtils.equalsIgnoreCase(type, "A3")) {
            return new LicenseType("A3");
        }
        if (StringUtils.equalsIgnoreCase(type, "B1")) {
            return new LicenseType("B1");
        }
        if (StringUtils.equalsIgnoreCase(type, "B2")) {
            return new LicenseType("B2");
        }
        if (StringUtils.equalsIgnoreCase(type, "C1")) {
            return new LicenseType("C1");
        }
        if (StringUtils.equalsIgnoreCase(type, "C2")) {
            return new LicenseType("C2");
        }
        if (StringUtils.equalsIgnoreCase(type, "C3")) {
            return new LicenseType("C3");
        }
        if (StringUtils.equalsIgnoreCase(type, "C4")) {
            return new LicenseType("C4");
        }
        return null;
    }
}
